package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.EcologyCollectionShareProfitConf;
import com.sc.nft.entity.EcologyShareProfitServiceCenterConf;
import com.sc.nft.mapper.EcologyShareProfitServiceCenterConfMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Objects;

/**
 * @Author：LiGen
 * @Package：com.sc.nft.dao
 * @Project：sc_metago
 * @name：DaoEcologyPointsWalletDao
 * @Date：2024/11/26 11:08
 * @Filename：DaoEcologyPointsWalletDao
 */
@Slf4j
@Repository
public class EcologyShareProfitServiceCenterConfDao extends ServiceImpl<EcologyShareProfitServiceCenterConfMapper, EcologyShareProfitServiceCenterConf> {
    public boolean saveAll(List<EcologyShareProfitServiceCenterConf> serviceCenterConfList) {
        return baseMapper.saveAll(serviceCenterConfList);
    }

    public List<EcologyShareProfitServiceCenterConf> listByConfId(Long confId) {
        LambdaQueryWrapper<EcologyShareProfitServiceCenterConf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (Objects.nonNull(confId)){
            lambdaQueryWrapper.eq(EcologyShareProfitServiceCenterConf::getConfId,confId);
        }
        return list(lambdaQueryWrapper);
    }


    public Boolean removeByConfId(Long confId) {
        LambdaUpdateWrapper<EcologyShareProfitServiceCenterConf> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(EcologyShareProfitServiceCenterConf::getConfId,confId);
        return remove(updateWrapper);
    }


    /**
     * 通过生态配置id获取分润配置的服务中心
     *
     * @param confId
     * @return
     */
    public List<EcologyShareProfitServiceCenterConf> getListByConfId(Long confId) {
        LambdaQueryWrapper<EcologyShareProfitServiceCenterConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(EcologyShareProfitServiceCenterConf::getConfId, confId);
        return list(wrapper);
    }
}
